package com.mcf.xiaolinju.interceptor;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

//配置拦截
@Configuration
public class Config implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new com.mcf.xiaolinju.interceptor.JwtInterceptor()).excludePathPatterns("/xiaolinju/user/login","/xiaolinju/user/gettoken","/xiaolinju/userreturn/getmessages","/xiaolinju/user/applogin","/captcha.jpg","/getCode","/xiaolinju/user/getUserCount","/xiaolinju/user/getUserAPI","/xiaolinju/user-details/getIdNumber","/xiaolinju/user/updatePasswordByUsername","/xiaolinju/uploadpicture","/image/*","/xiaolinju/user/getUserCount","/xiaolinju/tb-province/selectAll","/xiaolinju/tb-city/getallmessage","/xiaolinju/village/getvillageid","/xiaolinju/user/insertusermessage");//放掉某些特定不需要校验token的路由
    }
    @Override
    /**
     * 自定义静态资源映射目录
     */
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/image/**").addResourceLocations("file:"+System.getProperty("user.dir") +"/image/");
    }
}
